[Android] How to search and Highlight Text within an EditText
Posted
by marc
on Stack Overflow
See other posts from Stack Overflow
or by marc
Published on 2010-06-13T03:34:42Z
Indexed on
2010/06/13
3:42 UTC
Read the original article
Hit count: 845
I've searched high and low for something that seems to be a simple task. Forgive me, I am coming to Android from other programming languages and am new to this platform and Java.
What I want to do is create a dialog pop-up where a user enters text to search for and the code would take that text and search for it within all the text in an EditText control and if it's found, highlight it.
I've done this before, for example in VB and it went something similar to this pseudo code:
- grab the text from the (EditText) assign it to a string
- search the length of that string (character by character) for the substring, if it's found return the position (index) of the substring within the string.
- if found, start the (EditText).setSelection highlight beginning on the returned position for the length of
Does this make sense?
I just want to search a EditText for and when found, scroll to it and it'll be highlighted. Maybe there's something in Android/Java equivalent to what I need here?
Any help / pointers would be greatly appreciated
© Stack Overflow or respective owner